//
//  StockGoodsRankContentView.m
//  quxiangtao
//
//  Created by xbmios on 2018/7/26.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "StockGoodsRankContentView.h"
#import "StockGoodsRankContentTableViewCell.h"

static NSString *stockRankContentCellID = @"stockRankContentCellID";

@interface StockGoodsRankContentView ()<UITableViewDelegate, UITableViewDataSource>

@property (strong, nonatomic) UITableView *rankTableView;

@end

@implementation StockGoodsRankContentView

- (instancetype)init {
    
    if (self = [super init]) {
        
        [self addSubview:self.rankTableView];
        
    }

    return self;
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    __weak typeof(self) weakSelf = self;
    [self.rankTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.mas_left);
        make.right.mas_equalTo(weakSelf.mas_right);
        make.top.mas_equalTo(weakSelf.mas_top);
        make.bottom.mas_equalTo(weakSelf.mas_bottom);
        
    }];
}

#pragma mark -delegete\datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 5;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    StockGoodsRankContentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:stockRankContentCellID];

    if (!cell) {
        
        cell = [[StockGoodsRankContentTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:stockRankContentCellID];
        
    }
    
    cell.type = self.type;

    if (indexPath.item == 0) {
        
        cell.mvpIV.hidden = NO;
        
    }else {
        
        cell.mvpIV.hidden = YES;
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    return jisuan(100);
    
}

#pragma mark -lazy
- (UITableView *)rankTableView {
    
    if (!_rankTableView) {
        
        _rankTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        
        _rankTableView.delegate = self;
        _rankTableView.dataSource = self;
        
        _rankTableView.estimatedRowHeight = 0;
        _rankTableView.estimatedSectionFooterHeight = 0;
        _rankTableView.estimatedSectionHeaderHeight = 0;
        
        _rankTableView.showsVerticalScrollIndicator = NO;
        _rankTableView.showsHorizontalScrollIndicator = NO;
        
        _rankTableView.scrollEnabled = NO;
        
        _rankTableView.estimatedRowHeight = 0;
        _rankTableView.estimatedSectionHeaderHeight = 0;
        _rankTableView.estimatedSectionFooterHeight = 0;
        
        _rankTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        if (@available(iOS 11.0, *)) {
            
            _rankTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        }
    }
    
    return _rankTableView;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
